package com.erp.wallet.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.wallet.api.domain.ErpDistributionUserWallet;
import com.erp.wallet.mapper.ErpDistributionUserWalletMapper;
import com.erp.wallet.service.IErpDistributionUserWalletService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Description: 用户钱包Service业务层处理
 * @Author: j.zh
 * @Date: 2024/5/2
 * @Version: 4.0.0
**/
@RequiredArgsConstructor
@Service
public class ErpDistributionUserWalletServiceImpl implements IErpDistributionUserWalletService {

	@Resource
	ErpDistributionUserWalletMapper baseMapper;

	/**
	 * @Description: 创建钱包
	 * @Author: j.zh
	 * @Date: 2024/5/2
	 * @param userWallet
	 * @return java.lang.Long 钱包ID
	 * @Version: 4.0.0
	 **/
	@Override
	public ErpDistributionUserWallet insert(ErpDistributionUserWallet userWallet){
		baseMapper.insert(userWallet);
		return userWallet;
	}

	/**
	 * @Description: 根据分销员ID，获取钱包数据
	 * @Author: j.zh
	 * @Date: 2024/5/3
	 * @param distributionUserId
	 * @return com.ruoyi.wallet.api.domain.ErpDistributionUserWallet
	 * @Version: 4.0.0
	 **/
	@Override
	public ErpDistributionUserWallet getByDistributionUserId(Long distributionUserId){
		return baseMapper.selectOne(new LambdaQueryWrapper<ErpDistributionUserWallet>()
				.eq(ErpDistributionUserWallet::getDistributionUserId, distributionUserId));
	}

	/**
	 * @Description: 根据用户ID，获取钱包数据
	 * @Author: j.zh
	 * @Date: 2024/5/3
	 * @param userId
	 * @return com.ruoyi.wallet.api.domain.ErpDistributionUserWallet
	 * @Version: 4.0.0
	 **/
	@Override
	public ErpDistributionUserWallet getByUserId(Long userId){
		return baseMapper.selectOne(new LambdaQueryWrapper<ErpDistributionUserWallet>()
				.eq(ErpDistributionUserWallet::getUserId, userId));
	}
}
